package com.imis.module.api.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.imis.base.globle.Result;
import com.imis.module.api.bus.PersonalCenterBus;
import com.imis.module.api.model.ro.SysUserUpdateBasicInformationRO;
import com.imis.module.api.model.ro.SysUserUpdateEmailAddressRO;
import com.imis.module.api.model.ro.SysUserUpdatePhoneNumberRO;
import com.imis.module.base.BaseController;
import com.imis.module.system.model.vo.SysUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * PersonalCenterController<br>
 * 个人中心 前端控制器
 * </p>
 *
 * @author XinLau
 * @version 1.0
 * @since 2020年07月23日 11:14
 */
@Slf4j
@RestController
@RequestMapping("/personal/center")
@Api(tags = {"个人中心"})
@ApiSort(6)
public class PersonalCenterController extends BaseController<PersonalCenterBus> {

    @RequestMapping(value = "/queryBasicInformation", method = RequestMethod.GET)
    @ApiOperation(value = "查看基本信息", notes = "查看基本信息")
    @ApiOperationSupport(order = 1, author = "XinLau")
    public Result<SysUserVO> queryBasicInformation() {
        return service.queryBasicInformation();
    }

    @RequestMapping(value = "/updateBasicInformation", method = RequestMethod.PUT)
    @ApiOperation(value = "更新基本信息", notes = "更新基本信息")
    @ApiOperationSupport(order = 2, author = "XinLau")
    public Result updateBasicInformation(@RequestBody @Valid SysUserUpdateBasicInformationRO sysUserUpdateBasicInformation) {
        return service.updateBasicInformation(sysUserUpdateBasicInformation);
    }

    @RequestMapping(value = "/updatePhoneNumber", method = RequestMethod.PUT)
    @ApiOperation(value = "更新密保手机", notes = "更新密保手机")
    @ApiOperationSupport(order = 3, author = "XinLau")
    public Result updatePhoneNumber(@RequestBody @Valid SysUserUpdatePhoneNumberRO sysUserUpdatePhoneNumber) {
        return service.updatePhoneNumber(sysUserUpdatePhoneNumber);
    }

    @RequestMapping(value = "/updateEmailAddress", method = RequestMethod.PUT)
    @ApiOperation(value = "更新电子邮箱", notes = "更新电子邮箱")
    @ApiOperationSupport(order = 4, author = "XinLau")
    public Result updateEmailAddress(@RequestBody @Valid SysUserUpdateEmailAddressRO sysUserUpdateEmailAddress) {
        return service.updateEmailAddress(sysUserUpdateEmailAddress);
    }

}
